import request from '../../utils/request'




/**
 * 外汇认领
 * @param forexid
 * @param claimamount
 * @param claimamountunit
 * @param claimcstid
 * @returns {Promise.<void>}
 */
export async function addClaimForex({forexid, claimamount, claimamountunit, claimcstid}) {
    return request(apiPath.zbtie + "/api/forex/" + forexid +"/claim", {
        method: 'post',
        data: {forexid, claimamount, claimamountunit, claimcstid}
    });
}


/**
 * 删除外汇认领
 * @param forexId
 * @param claimId
 * @returns {Promise.<void>}
 */
export async function deleteClaimForex({forexId, claimId}) {
    return request(apiPath.zbtie + "/api/forex/" + forexId +"/claim/" + claimId, {
        method: 'delete'
    });
}


/**
 * 提交认领记录
 * @param forexid
 * @returns {Promise.<void>}
 */
export async function submitClaimForex({forexId}) {
    return request(apiPath.zbtie + "/api/forex/" + forexId +"/apply", {
        method: 'post',
    });
}


/**
 * 分页领取记录
 * @param forexId
 * @returns {Promise.<void>}
 */
export async function getClaimForexList({forexId, page}) {

    return request(apiPath.zbtie + "/api/forex/" + forexId + "/claims", {
        method: 'get',
        data: {
            page: page.page,
            size: page.size
        }
    });
}

/**
 * 分页获取未关联订单
 * @param cstId
 * @param page
 * @returns {Promise.<void>}
 */
export async function getUnrelatorderForexList({forexId, orderNo, page}) {
    return request(apiPath.zbtie + "/api/forex/" + forexId +"/unrelatorder", {
        method: 'get',
        data: {
            orderNo,
            page: page.page,
            size: page.size
        }
    });
}

/**
 * 查询关联的订单
 * @param forexId
 * @param page
 * @returns {Promise.<void>}
 */
export async function getRelatedorderForexList({forexId, page}) {
    return request(apiPath.zbtie + "/api/forex/" + forexId  + "/relatedorder", {
        method: 'get',
        data: {
            page: page.page,
            size: page.size
        }
    });
}


/**
 * 外汇关联
 * @param forexid
 * @param orderid
 * @param exportamount
 * @param relateamount
 * @returns {Promise.<void>}
 */
export async function addRelateForex({forxid, orderid, exportamount, relateamount}) {
    return request(apiPath.zbtie + "/api/forex/relate", {
        method: 'post',
        data: {forxid, orderid, exportamount, relateamount}
    });
}

/**
 * 取消外汇关联
 * @param forxid
 * @param orderid
 * @param relateamount
 * @returns {Promise.<void>}
 */
export async function cancelRelateForex({id, forxid, orderid, relateamount}) {
    return request(apiPath.zbtie + "/api/forex/cancelrelate", {
        method: 'post',
        data: {id, forxid, orderid, relateamount}
    });
}


/**
 * 确认外汇收齐
 * @param orderId
 * @returns {Promise.<void>}
 */
export async function confirmfinishForex({orderId}) {
    console.info(orderId);
    return request(apiPath.zbtie + "/api/forex/confirmfinish", {
        method: 'post',
        data: {orderId}
    });
}

/**
 * 取消外汇收齐
 * @param orderId
 * @returns {Promise.<void>}
 */
export async function cancelfinishForex(data) {
    return request(apiPath.zbtie + "/api/forex/cancelForexFinish", {
        method: 'post',
        data
    });
}
